﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using NetCoreProject.Api.Common;
using NetCoreProject.Api.Filters;
using NetCoreProject.Api.Infrastructure.Validator;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Security.Claims;

namespace NetCoreProject.Api.Controllers.Authentication
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class Oath2Controller: ReponseResult
    {
        public readonly ILogger<Oath2Controller> _logger;
        public Oath2Controller(ILogger<Oath2Controller> logger)
        {
            _logger = logger;
        }

        [HttpGet]
        public ActionResult GetToken(string CorpID="",string SecretKey="") 
        {

            return CreateRespone(response =>
            {
                if (string.IsNullOrEmpty(CorpID) || string.IsNullOrEmpty(SecretKey)) 
                {
                    response.Code = 10000;
                    response.Data = "";
                    response.Msg = "票据不合法";
                    return;
                }
                if (CorpID == "Admin" && SecretKey == "Admin123")
                {   
                    response.Code = 200;
                    response.Data = "";
                    response.Msg = "Token获取成功!";
                } 
                else 
                {
                    response.Code = 10000;
                    response.Data = "";
                    response.Msg = "票据不合法";
                }
            });
        }
    }
}